﻿using System;
using System.Collections.Generic;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace OptikinetiqControls
{
    public class DrawRectangle
    {
        public RectangleF rect;

        public float rotate;

        private Color _selectColor;
        public Color selectColor
        {
            get { return _selectColor; }
        }

        private Color _penColor;
        public Color penColor
        {
            get { return _penColor; }
            set
            {
                _penColor = value;

                int r = 255 - value.R;
                int g = 255 - value.G;
                int b = 255 - value.B;
                _selectColor = Color.FromArgb(r, g, b);
            }
        }

        private float _penSize;

        public float penSize
        {
            get { return _penSize; }
            set { _penSize = value; }
        }

        public bool isSelect;

        public PointF GetRectCenter()
        {
            float centerX = (rect.X + rect.Width) / 2;
            float centerY = (rect.Y + rect.Height) / 2;

            return new PointF(centerX, centerY);
        }

        public PointF GetTL()
        {
            return new PointF(rect.X, rect.Y);
        }

        public PointF GetTR()
        {
            return new PointF(rect.X + rect.Width, rect.Y);
        }

        public PointF GetBR()
        {
            float r = rect.X + rect.Width;
            float b = rect.Y + rect.Height;

            return new PointF(r, b);
        }

        public PointF GetBL()
        {
            return new PointF(rect.X, rect.Y + rect.Height);
        }


        public SizeF GetSize()
        {
            float w = GetBR().X - GetTL().X ;
            float h = GetBR().Y - GetTL().Y ;

            return new SizeF(w, h);
        }

        public PointF GetCenter()
        {
            float x = rect.X + rect.Width / 2;
            float y = rect.Y + rect.Height / 2;

            return new PointF(x, y);
        }

        public double GetArea() {
            return rect.Width * rect.Height;
        }

        public double GetPermiter() {
            return (rect.Width + rect.Height) * 2;
        }

        public float GetCenterSize() {
            return Math.Min(rect.Width, rect.Height) / 10;
        }
    }
}
